import net.minidev.json.JSONObject;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * @Author lzc
 * @Date 2022/10/6 14:28
 */
public class Demo2 {
    public static void main(String[] args) {
        JSONObject obj = new JSONObject();
        obj.put("a", 97);
        obj.put("b", 98);
        obj.put("c", 99);
    
        List<String> columns = Arrays.asList("a,c".split(","));
    
        System.out.println(obj);
        Set<String> keys = obj.keySet();
        /*for (String key : keys) {
            if (!columns.contains(key)) {
                keys.remove(key);
            }
        }*/
        /*Iterator<String> it = keys.iterator();
        while (it.hasNext()) {
            String next = it.next();
            if (!columns.contains(next)) {
                it.remove();
            }
        }*/
    
        keys.removeIf(next -> !columns.contains(next));
    
        System.out.println(obj);
    
    
    }
}
